import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:mtf/app/routes/app_pages.dart';
import 'package:mtf/app/utils/cache/AppCahche.dart';

import '../../../R.dart';
import '../mine_module/mine_page.dart';
import '../news_module/news_page.dart';
import '../stock_market_module/stock_market_page.dart';
/**
 * GetX Template Generator - fb.com/htngu.99
 * */

class homeController extends GetxController {
  final _curIndex = 0.obs;

  set currentPage(index) => _curIndex.value = index;

  get currentPage => _curIndex.value;

  //Page页面集合
  late List<Widget> tabPageBodies;

  /// 底部BottomNavigationBarItem

  /// PageView页面控制器
  late PageController pageController;

  @override
  void onInit() {
    super.onInit();
    tabPageBodies = <Widget>[newsPage(), stockMarketPage(), minePage()];
    pageController = PageController(initialPage: currentPage);

  }

  @override
  void onReady() {
    
  }
  switchBottomTabBar(int index) {
    pageController.animateToPage(index,
        duration: Duration(seconds: 1), curve: Curves.fastLinearToSlowEaseIn);
    pageController.jumpToPage(index);
  }

  onPageChanged(int index) {
    currentPage = index;
  }
}
